from datetime import datetime
from fastapi import APIRouter
from config.settings import Settings
from schemas.baseResponse import BaseResponse, ErrorResponse, SuccessResponse
from utils.businessException import BusinessException
from utils.decorators import skip_auth

router = APIRouter(prefix="/system", tags=[__name__])
settings = Settings()
@router.get("/info")
@skip_auth
async def info():
    return SuccessResponse({
        'AppName': 'demo',
        'Env': settings.ENV,
        'DateTimeNow': datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
        'Version': '20250401'
    })

@router.get("/test")
async def root(type: str):
    if type == "0":
        return SuccessResponse(123)
    elif type == "1":
        return BaseResponse(data=123)
    elif type == "2":
        return ErrorResponse(code=500,error="xxx")
    elif type == "3":
        raise BusinessException("xxx")